// *************************************************************************************************
//
// MK3D Engine
// --------------------------------------
// Copyright (C) 2007-2011 Zeb (mailto: zebbey@gmail.com)
//
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
// *************************************************************************************************

#ifndef __H_MK_HEADER__
#define __H_MK_HEADER__

// disable DLL export warning.
#pragma warning (disable : 4251)

// disable CRT secure warning.
#define _CRT_SECURE_NO_WARNINGS

// STL header
#include <vector>
#include <string>
#include <list>
#include <fstream>
#include <hash_map>
#include <set>
#include <sstream>
#include <iostream>

// CRT header
#include <stdio.h>
#include <stdlib.h>
#include <direct.h>

// d3dx header. We use d3dx for math calculate.
#include <d3dx9.h>
#pragma comment(lib, "d3dx9.lib")

// MM system
#pragma comment(lib, "winmm.lib")

// XML Parser
#include "TinyXML.h"

// zlib
#include "zlib.h"
#include "zzip/zzip.h"

// DevIL
#include "IL/il.h"
#include "IL/ilu.h"

// define DLL export macro.
#ifdef MK3DE_EXPORTS
#define MK3DE_API __declspec(dllexport)
#else
#define MK3DE_API __declspec(dllimport)
#endif

namespace MK3DE
{
	const char MK3D_ENGINE[] = "MK3D Engine";
	const char MK3D_VERSION[] = "0.2.0";

	const float MK_PI = 3.1415926f;
	const float MK_HALF_PI = MK_PI / 2;
	const float MK_QUAR_PI = MK_PI / 4;
	const float MK_DOUBLE_PI = MK_PI * 2;
	const float MK_EPSILON = 0.000001f;
	const float MK_ANGLE_TO_RAD_FACTOR = MK_PI / 180.0f;
	const float MK_MAX_FLOAT = 1e33f;
	const float MK_MIN_FLOAT = -1e33f;

#define MK_DWORD_AS_FLOAT(DW) (*(FLOAT*)&(DW))
#define MK_FLOAT_AS_DWORD(F) (*(DWORD*)&(F))
#define MK_FLOAT_SIGN(F) ((MK_FLOAT_AS_DWORD(F) & 0x80000000L))
#define MK_ALMOST_ZERO(F) ((MK_FLOAT_AS_DWORD(F) & 0x7f800000L)==0)
#define MK_IS_SPECIAL(F)  ((MK_FLOAT_AS_DWORD(F) & 0x7f800000L)==0x7f800000L)
#define MK_ANGLE_TO_RAD(A) (A * MK_ANGLE_TO_RAD_FACTOR)

#define MK_COLOR_ARGB(a,r,g,b) ((DWORD)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
#define MK_COLOR_GETA(c) (((c)&0xff000000)>>24)
#define MK_COLOR_GETR(c) (((c)&0x00ff0000)>>16)
#define MK_COLOR_GETG(c) (((c)&0x0000ff00)>>8)
#define MK_COLOR_GETB(c) ((c)&0x000000ff)

#define DEF_SET_GET(T, C) \
	inline void Set##C(T set) { C = set; } \
	inline T Get##C() { return C; }
};

#define MK_PROFILER_ENABLE 1

#endif /* __H_MK_HEADER__ */